import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { SFSchema, SFComponent } from '@delon/form';


import { SupDic } from 'lbf';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';

@Component({
  selector: 'app-test01-test0103',
  templateUrl: './test0103.component.html',
})
export class Test01Test0103Component implements OnInit {
  expandForm = false;
  schema: SFSchema = {};
  url:string ='http://60.191.106.236:81/WebReport/ReportServer?reportlet=中心按人属性查表.cpt'
  url1:string = this.url
  newurl :any
  constructor(private http: _HttpClient, private supdic: SupDic,private sanitizer:DomSanitizer) {}



  @ViewChild('sf', { static: false }) sf: SFComponent;

  ngOnInit() {
    this.inituel();
  }

  expand() {
    this.expandForm = !this.expandForm;
    if (this.expandForm) {
      console.log('展开');
      this.schema = {
        properties: {
          AAC004: {
            title: '性别',
            type: 'string',
            enum: this.supdic.getSFDic('AAC004'),
            ui: {
              widget: 'select',
              mode: 'tags',
              grid: {
                span: 6,
              },
            },
          },
          KKB001: {
            title: '签约情况',
            type: 'string',
            enum: this.supdic.getSFDic('YESNO'),
            ui: {
              widget: 'select',
              mode: 'tags',
              grid: {
                span: 6,
              },
            },
          },
          AKE524: {
            title: '慢病情况',
            type: 'string',
            enum: this.supdic.getSFDic('AKE524'),
            ui: {
              widget: 'select',
              mode: 'tags',
              grid: {
                span: 6,
              },
            },
          },

          CAA001: {
            title: '所属乡镇',
            type: 'string',
            enum: this.supdic.getSFDic('CAA001'),
            ui: {
              widget: 'select',
              mode: 'tags',
              grid: {
                span: 12,
              },
            },
          },
          AKE500: {
            title: '所在健共体',
            type: 'string',
            enum: this.supdic.getSFDic('AKE500'),
            ui: {
              widget: 'select',
              mode: 'tags',
              grid: {
                span: 12,
              },
            },
          },
        },
        ui: {
          spanLabelFixed: 120,
          grid: {
            span: 24,
          },
        },
      };
    } else {
      console.log('收起');
      this.schema = {
        properties: {},
        ui: {
          spanLabelFixed: 120,
          grid: {
            span: 8,
          },
        },
      };
    }
  }

  show() {
    document.getElementById('div1').style.display = 'block';
  }

  reset() {
    this.sf.reset();
    document.getElementById('div1').style.display = 'none';
  }

  getData() {
    let temp={para:this.sf.value};
    //this.url =this.url1+"&"+JSON.stringify(this.sf.value)
    this.url =this.url1+"&PARAM="+JSON.stringify(temp);
    console.log('url',this.url)
    this.inituel()
  }/*
  trustUrl(url: string) {
     return this.sanitizer.bypassSecurityTrustResourceUrl(url);
   }*/

   ifrmeee:SafeResourceUrl;
   inituel(){
    this.ifrmeee=this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
   }
}
